package org.builder;

import java.util.ArrayList;
import java.util.Iterator;

public abstract class ProductModel {
	// 方法执行的序列
	private ArrayList<String> sequence = new ArrayList<String>();

	public void setSequence(ArrayList<String> sequence) {
		this.sequence = sequence;
	}

	// 具体产品的业务方法1
	protected abstract void method1();

	// 具体产品的业务方法2
	protected abstract void method2();

	protected abstract void method3();

	// 模板的方法，并由sequence决定方法的执行顺序
	final public void templeMethod() {
		for (int i = 0; i < this.sequence.size(); i++) {
			String actionName = this.sequence.get(i);
			if (actionName.equalsIgnoreCase("method1")) {
				this.method1();
			} else if (actionName.equalsIgnoreCase("method2")) {
				this.method2();
			} else if (actionName.equalsIgnoreCase("method3")){
				this.method3();
			}
			else{
				
			}
		}
	}
}
